// src/utils/permission.ts
import { App } from "vue";
import { IViewHooks } from '@/types/interface';
import { useAppStore } from '@/store/index';
import { checkPermission, getDictLabel } from "@/utils/utils";


// 注册全局方法
export function installPermission(app: App) {
  app.config.globalProperties.$hasPermission = function(key: string) {
    // 在运行时获取当前实例
    // console.log("useAppStore--->",useAppStore().state.permissions)//获取当前登录人的所有权限
    return checkPermission(useAppStore().state.permissions,key);
  };

  // // 注册自定义指令
  // app.directive('permission', {
  //   mounted(el, binding) {
  //     const instance = getCurrentInstance();
  //     if (!checkPermission(binding.value, instance?.proxy || instance)) {
  //       el.parentNode?.removeChild(el);
  //     }
  //   }
  // });
}
